package com.example.goodog.adapters;


import java.util.Locale;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.android.wizardpager.AbstractWizardModel;
import com.example.android.wizardpager.AddStoreWizardModel;
import com.example.goodog.ComparatorByDistance;
import com.example.goodog.ComparatorByName;
import com.example.goodog.R;
import com.example.goodog.interfaces.IAddWizard;
import com.example.goodog.items.StoreItem;

public class StoreAdapter extends ItemAdapter implements IAddWizard{

	public StoreAdapter(Context c, int PageNumber) {
		super(c, StoreItem.class.getSimpleName(), R.layout.store_item, PageNumber);
		AddComparator(new ComparatorByDistance(0, 0));
		AddComparator(new ComparatorByName());
		// TODO Auto-generated constructor stub
	}
	

	
	public View getView(int position, View convertView, ViewGroup parent) {
		View List = super.getView(position, convertView, parent);
		StoreItem item = ((StoreItem)items.get(position));
		
		TextView StoreNameText = (TextView)List.findViewById(R.id.storeNameTextView);
		StoreNameText.setText(item.Name);
		
		//TextView StorePhoneText = (TextView) List.findViewById(R.id.storePhoneTextView);
		//StorePhoneText.setText(item.PhoneString);
		
		//TextView StoreClientsText = (TextView) List.findViewById(R.id.storeClientsTextView);
		//StoreClientsText.setText(String.valueOf(item.Clients));
		
		TextView StoreAddressText = (TextView) List.findViewById(R.id.storeAddressText);
		StoreAddressText.setText(String.valueOf(item.Address));
		
		ImageView StoreImage = (ImageView) List.findViewById(R.id.storeImage);
		Bitmap bmp = item.getBitmap();
		if(bmp != null)
		{
			StoreImage.setImageBitmap(bmp);
		}
		
		AddButtonsToToolbar(List, item);
		
		return List;
	}

	public String GetTitle()
	{
		Locale l = Locale.getDefault();
		return context.getString(R.string.stores).toUpperCase(l);
	}

	@Override
	public AbstractWizardModel getAddWizard(Context c) {
		return new AddStoreWizardModel(c);
	}
	

}

